<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div id="app">
    test
  </div>
  <script>
    
    class EventEmitter {
      constructor(){
        // { 'click': [callback] }
        this.subs = Object.create(null)
      }


      $on (eventType, callback){
        this.subs[eventType] = this.subs[eventType] || []
        this.subs[eventType].push(callback)
      }

      $emit(event, value){
        this.subs[event].map(cb => cb(value))
      }
    }

    let vm = new EventEmitter()

    vm.$on('click', ()=> {
      console.log('click1');
    })
    vm.$on('click', (val)=> {
      console.log('click12', val);
    })

    vm.$emit('click', 'ttq')
  </script>
</body>

</html>